home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / DATABASE / PROGRESS / STATDLG.PAS < prev    next >
Pascal/Delphi Source File  |  1996-06-16  |  3KB  |  98 lines

  1. {
  2.  Unit Name:      StatDlg
  3.  Unit Type:      Dialog
  4.  
  5.  Created:        18 December 1995
  6.  Last Modified:   1 June     1996
  7.  
  8.  Authors:        CNS International B.V.
  9.                  Feel free to use this unit as you like.
  10.  
  11.  Description: This dialog is an example of using the TDBProgress
  12.               component. To use this dialog, perform the following
  13.               actions:
  14.  
  15.               1. Add this file to your project
  16.               2. Add this unit to the 'uses' clause of the
  17.                  units which will be performing database actions
  18.               3. Place 'dlgStatus.Show;' before and 'dlgStatus.Hide;'
  19.                  after the database operations for which you want to
  20.                  provide feedback.
  21.               4. Compile and run.
  22.  }
  23.  
  24. unit StatDlg;
  25.  
  26. interface
  27.  
  28. uses
  29.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  30.   Forms, Dialogs, StdCtrls, Buttons, Gauges, ExtCtrls, DB,
  31.   DBTables, DBProgrs;
  32.  
  33. type
  34.   TdlgStatus = class(TForm)
  35.     panBackground: TPanel;
  36.     gauDBStatus: TGauge;
  37.     cmdAbort: TBitBtn;
  38.     DBProgress1: TDBProgress;
  39.     procedure FormCreate(Sender: TObject);
  40.     procedure cmdAbortClick(Sender: TObject);
  41.     procedure DBProgress1StatusChange(Sender: TObject; var Abort: Boolean);
  42.     procedure FormActivate(Sender: TObject);
  43.   private
  44.     { Private declarations }
  45.     bPerformAbort: Boolean;
  46.   public
  47.     { Public declarations }
  48.   end;
  49.  
  50. var
  51.   dlgStatus: TdlgStatus;
  52.  
  53. implementation
  54.  
  55. {$R *.DFM}
  56.  
  57. procedure TdlgStatus.FormCreate(Sender: TObject);
  58. begin
  59.    { Clear abort flag }
  60.    bPerformAbort := False;
  61. end;
  62.  
  63. procedure TdlgStatus.cmdAbortClick(Sender: TObject);
  64. begin
  65.    { Set the Abort flag to true }
  66.    bPerformAbort := True;
  67. end;
  68.  
  69. procedure TdlgStatus.DBProgress1StatusChange(Sender: TObject;
  70.   var Abort: Boolean);
  71. begin
  72.    if DBProgress1.Percentage <> -1 then
  73.    begin
  74.       gauDBStatus.Visible := True;
  75.       gauDBStatus.Progress := DBProgress1.Percentage;
  76.    end
  77.    else
  78.    begin
  79.       gauDBStatus.Visible := False;
  80.       panBackground.Caption := DBProgress1.LastMessage;
  81.    end;
  82.    Abort := bPerformAbort;
  83.    { Reset abort flag after aborting }
  84.    if bPerformAbort then bPerformAbort := False;
  85.    { Make sure abort button can be pressed }
  86.    Application.ProcessMessages;
  87.  
  88. end;
  89.  
  90. procedure TdlgStatus.FormActivate(Sender: TObject);
  91. begin
  92.    { Make sure the progress component is turned on }
  93.    DBProgress1.Activate;
  94.    Update;
  95. end;
  96.  
  97. end.
  98.